package com.tqfframe.rabbitmq.service;

import com.tqfframe.rabbitmq.constants.RabbitConstants;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author: Qifeng Tang
 * @date: 2022/11/17 10:43
 * @Version 1.0
 **/
@Service
public class DeadService {
    @Autowired
    private RabbitTemplate rabbitTemplate;


    // 发送延时信息
    public void send(String msg,String expiration){
//        MessagePostProcessor messagePostProcessor = message -> {
//            //消息过期时间，毫秒
//            message.getMessageProperties().setExpiration(expiration);
//            return message;
//        };
//        rabbitTemplate.convertAndSend(RabbitConstants.DEAD_COMMON_EXCHANGE,RabbitConstants.DEAD_COMMON_ROUTINGKEY, (Object) msg
//                , messagePostProcessor);
        rabbitTemplate.convertAndSend(RabbitConstants.DEAD_COMMON_EXCHANGE,RabbitConstants.DEAD_COMMON_ROUTINGKEY, msg);
    }

}
